﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Xml;
namespace Test
{
    public class XmlHelper
    {
        /// <summary>
        /// xml的根
        /// </summary>
        public XmlDocument Doc{ get; set; }
        /// <summary>
        /// 初始化xml的跟
        /// </summary>
        /// <param name="path"></param>
        public XmlHelper(string path)
        {
            Doc = new XmlDocument();
            Doc.Load(path);
        }
       /// <summary>
       /// 根据节点的名字找到所有的value的list的集合
       /// </summary>
       /// <param name="Key">节点名字</param>
       /// <returns></returns>
        public  List<string>  GetValueByKey(string Key)
        {
            List<string> list = new List<string>();
            XmlNodeList nodes = Doc.SelectNodes("//"+Key);
            foreach (XmlNode node in nodes)
            {
                list.Add(node.InnerText);
            }
            return list;

        }
    }
}
